package org.lex.net.ftp.util;

import org.lex.net.event.ProtocolEvent;
import org.lex.net.event.ProtocolListener;
import org.lex.net.log.Log;

public class LogListener implements ProtocolListener {
	private final Log log;

	public LogListener(Log log) {
		this.log = log;
	}

	public void commandSent(ProtocolEvent e) {
		String msg = null;
		if (e.getCommand().equals("PASS"))
			msg = "PASS ********";
		else
			msg = e.getMessage();
		log.send(e.getSource(), msg);
	}

	public void replyReceived(ProtocolEvent e) {
		log.reply(e.getSource(), e.getMessage());
	}
}
